home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
datedres.swf
/
scripts
/
CSnow_.as
Wrap
Text File
|
2013-04-24
|
3KB
|
123 lines
function CSnow()
{
this.Init();
}
CSnow.prototype = new MovieClip();
CSnow.prototype.Init = function()
{
if(this._width < 100)
{
this._width = 100;
}
if(this._height < 100)
{
this._height = 100;
}
this.m_nRight = this._width;
this.m_nBottom = this._height;
this.ins_Mask._width = this._width;
this.ins_Mask._height = this._height;
this._xscale = 100;
this._yscale = 100;
this.setMask(this.ins_Mask);
this.ConfirmValue();
this.CreateSnow();
};
CSnow.prototype.ConfirmValue = function()
{
if(this.m_nSnowSpeed <= 0)
{
this.m_nSnowSpeed = 5;
}
if(this.m_nSnowSpeed > 100)
{
this.m_nSnowSpeed = 100;
}
if(this.m_nLeftWind > 10)
{
this.m_nLeftWind = 10;
}
if(this.m_nRightWind > 10)
{
this.m_nRightWind = 10;
}
};
CSnow.prototype.CreateSnow = function()
{
this.attachMovie(this.m_strSnowMovie,"Snow_Test",1);
if(this.Snow_Test == undefined)
{
this.m_strSnowMovie = "DefaultSnow";
}
this.Snow_Test.removeMovieClip();
i = 1;
while(i < this.m_nSnowMax)
{
this.attachMovie(this.m_strSnowMovie,"Snow" + i,i);
eval("this.Snow" + i)._x = -1;
eval("this.Snow" + i).onEnterFrame = this.SnowOnEnterFrame;
i++;
}
};
CSnow.prototype.SetSnow = function(snowMax)
{
if(this.m_nSnowMax > snowMax)
{
i = snowMax;
while(i < this.m_nSnowMax)
{
eval("this.Snow" + i).removeMovieClip();
i++;
}
}
else
{
i = this.m_nSnowMax;
while(i < snowMax)
{
this.attachMovie(this.m_strSnowMovie,"Snow" + i,i);
eval("this.Snow" + i)._x = -1;
eval("this.Snow" + i).onEnterFrame = this.SnowOnEnterFrame;
i++;
}
}
this.m_nSnowMax = snowMax;
};
CSnow.prototype.SetSpeed = function(Speed)
{
this.m_nSnowSpeed = Speed;
this.ConfirmValue();
};
CSnow.prototype.SetLeftWind = function(leftWind)
{
this.m_nLeftWind = leftWind;
this.ConfirmValue();
};
CSnow.prototype.SetRightWind = function(rightWind)
{
this.m_nRightWind = rightWind;
this.ConfirmValue();
};
CSnow.prototype.SnowOnEnterFrame = function()
{
if(this._x <= 0 or this._x > this._parent.m_nRight or this._y > this._parent.m_nBottom)
{
this._parent.ResetSnowEntty(this);
return undefined;
}
this._x += this.t_nSpeedX;
this._y += this.t_nSpeedY;
};
CSnow.prototype.ResetSnowEntty = function(obj)
{
var sz = random(120) - 10;
obj._xscale = sz;
obj._yscale = sz;
obj._x = random(this.m_nRight) + 1;
obj._y = random(this.m_nBottom) + 1;
obj.t_nSpeedX = this.m_nRightWind + random(this.m_nRightWind) - (this.m_nLeftWind + random(this.m_nLeftWind));
obj.t_nSpeedY = 2 + this.m_nSnowSpeed * sz * 0.01;
obj.gotoAndPlay(1);
};
Object.registerClass("CSnow_",CSnow);